package com.derek.omshopping.ui.classify;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.derek.omshopping.R;
import com.derek.omshopping.bean.classify.ClassifyDetailBean;

import java.util.List;

/**
 * Created by My on 2016/10/24.
 */

public class ClassifyDetailAdapter extends BaseAdapter {
    private Context context;
    private List<ClassifyDetailBean.PdtsAndActpicsBean.SetListBean.ContentListBean> list;
    public ClassifyDetailAdapter(Context context,List<ClassifyDetailBean.PdtsAndActpicsBean.SetListBean.ContentListBean> list){
        this.context=context;
        this.list=list;

    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        viewHolder holder=null;
        if(convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.activity_classify_detail_item,null);
            holder=new viewHolder();
            holder.tv1= (TextView) convertView.findViewById(R.id.tv_classifydetailname);
            holder.tv2= (TextView) convertView.findViewById(R.id.tv_classifydetailprice);
            holder.iv= (ImageView) convertView.findViewById(R.id.iv_classifydetail);
            convertView.setTag(holder);
        }else{
            holder= (viewHolder) convertView.getTag();
        }
        holder.tv1.setText(list.get(position).getConts_title_nm());
        holder.tv2.setText(list.get(position).getItem_price());
        Glide.with(context).load(list.get(position).getItem_image()).placeholder(R.mipmap.meiri_logo).crossFade().into(holder.iv);

        return convertView;
    }
    static class viewHolder{
        TextView tv1,tv2;
        ImageView iv;
    }
}